package _mst;

import _object.ListNode;

/**
 * 面试题 02.07. 链表相交
 */
public class T0207 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        if (headA == null || headB == null) return null;
        ListNode curA = headA, curB = headB;
        while (true) {
            if (curA == curB) return curA;
            curA = curA == null ? headB : curA.next;
            curB = curB == null ? headA : curB.next;
        }
    }
}
